﻿@if (heatmapData == null)
{
	<Loading></Loading>
}
else
{
    <Heatmap @ref=_chart Data="heatmapData" Config="config" />
}

@code {
    public class HeatmapData
    {
        public decimal x { get; set; }
        public decimal y { get; set; }
        public decimal value { get; set; }
    }
    [Parameter]
    public object[] heatmapData { get; set; }
    [Parameter]
    public int height { get; set; }
    [Parameter]
    public int width { get; set; }
    [Parameter]
    public decimal xMax { get; set; }
    [Parameter]
    public decimal yMax { get; set; }
    private IChartComponent _chart;
    protected override async void OnParametersSet()
    {
        config.Height = height;
        config.Width = width;
        if (_chart != null)
        {
            await _chart.UpdateConfig(config);
            await _chart.UpdateChart(data : heatmapData);
        }
        base.OnParametersSet();
    }

    readonly HeatmapConfig config = new HeatmapConfig
    {
            HeatMapType="density",
            XField = "x",
            YField = "y",
            ColorField = "value",
            Color = new[] { "#295599", "#3e94c0", "#78c6d0", "#b4d9e4", "#fffef0", "#f9cdac", "#ec7d92", "#bc448c" },
            XAxis = new Axis
            {
                Title = new()
                {
                    Text="标题长度(字)",
                },
                Visible = true,
                Min =0,
                Nice = false
            },
            YAxis = new Axis
            {
                Title = new()
                {
                    Text = "视频长度(分)",
                },
                Visible = true,
                Min=0
            }
        };



}